package com.example.demo.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/demo")
@Slf4j
public class CustomController {
    public CustomController(CustomService customService) {
        this.customService = customService;
        log.info(" - - - - - - CustomController Init - - - - - - ");
    }

    @PostConstruct
    public void postConstruct(){
        log.info(" - - - - - - CustomController PostConstruct - - - - - - ");
    }

    @Resource
    private CustomService customService;

    @GetMapping("/create")
    public String create() {
        return customService.create();
    }

    @GetMapping("/query")
    public List<Map<String, Object>> query() {
        return customService.query();
    }

    @GetMapping("/add")
    public String add() {
        return customService.add();
    }

    @GetMapping(value = "/getImage", produces = "application/json;charset=UTF-8")
    public ResponseEntity<byte[]> getImage(String pic) {
        return customService.getImage(pic);
    }
}
